{include file="default/base/header" /}
<style>
    tr {
        display: flex;
        align-items: center;
        border-top: 1px dotted #CBE9F3 !important;
    }

    tr td {
        flex: 0 0 50%;
        display: flex !important;
        align-items: center;
        border-top: none !important;
    }

    tr > td > div {
        flex: 1 0 auto;
    }

    /*tr>td>input{
        flex: 0 0 200px;
    }*/
    tr > td > .title {
        flex: 0 0 80px;
    }
</style>
<div class="page" style="    overflow: hidden;">
    <form method="post" name="remark_form" id="remark_form"
          action="{:url('Sellergoodsadd/perfect_goods_content_save')}">
        <input type="hidden" value="{$commonid}" name="commonids">


        <table class="ds-default-table nobdb">
            <tbody>
            <tr>
                <td>
                    <span class="title">厂家商品编码:</span><input name="goods_code"
                                                             value="{$goods_info.goods_code|default=''}"
                                                             type="text"><span></span>
                </td>
                <td class="vatop rowform onoff">
                    <span class="title">商品厂家:</span><input name="goods_factory"
                                                           value="{$goods_info.goods_factory|default=''}"
                                                           type="text"><span></span>
                </td>

            </tr>
            <tr class="noborder">
                <td class="vatop rowform onoff">
                    <span class="title">商品产地:</span>
                    <?php if(isset($goods_info['address'])&&$goods_info['address']!=''){?>
                    <div id="save_area" style="display: none;">
                        <select name="area_id1" style="width:auto;" id="area_id1"
                                data-action="{if isset($edit_goods_sign)}{:url('Sellergoodsonline/ajax_get_area_class')}{else/}{:url('Sellergoodsadd/ajax_get_area_class')}{/if}">
                            <option value="0">{$Think.lang.ds_please_choose}...</option>
                            {notempty name="top_area_class"}
                            {foreach name="top_area_class" item="v" key="k" }
                            <option value="{$v.area_id}">{$v.area_name}</option>
                            {/foreach}
                            {/notempty}
                        </select>

                        <select name="area_id2" id="area_id2" style="width: auto;">
                            <option value="">{$Think.lang.ds_please_choose}...</option>
                        </select><span></span>
                    </div>
                    <div id="edit_area">{$goods_info['address']}
                        <input type="button" value="编辑" style="font-size: 8px;width: 47px;!important;"
                               id="edit_area_button">
                        <input type="hidden" name="area_id1" value="{$goods_info.area_id1}">
                        <input type="hidden" name="area_id2" value="{$goods_info.area_id2}" id="save_area_id2">
                    </div>
                    <?php }else{ ?>
                    <select name="area_id1" style="width: auto;" id="area_id1"
                            data-action="{if isset($edit_goods_sign)}{:url('Sellergoodsonline/ajax_get_area_class')}{else/}{:url('Sellergoodsadd/ajax_get_area_class')}{/if}">
                        <option value="0">{$Think.lang.ds_please_choose}...</option>
                        {notempty name="top_area_class"}
                        {foreach name="top_area_class" item="v" key="k" }
                        <option value="{$v.area_id}">{$v.area_name}</option>
                        {/foreach}
                        {/notempty}
                    </select>
                    <select name="area_id2" id="area_id2" style="width: auto;">
                        <option value="">{$Think.lang.ds_please_choose}...</option>
                    </select><span></span>
                    <?php } ?>
                </td>
                <td class="vatop rowform onoff">
                    <span class="title">运费模板:</span>
                    <select name='waybill_id' style="width: auto;" id="waybill_id"
                            data-action="{:url('Sellergoodsadd/ajax_waybill')}">
                        <option value="">请选择</option>
                        <?php foreach($waybill_info as $k=>$v){?>
                        <option value="<?php echo $v['waybill_id']; ?>"
                        <?php if(isset($goods_info['waybill_id'])&&$v['waybill_id']== $goods_info['waybill_id']){?>
                        selected="selected"<?php }?>><?php echo $v['waybill_name']; ?></option>
                        <?php }?>
                    </select><span></span>
                </td>

            </tr>

            <tr class="noborder">
                <td class="vatop rowform onoff">
                    <span class="title">商品发货地:</span>
                    <?php if(isset($goods_info['hair_address'])&&$goods_info['hair_address']!=''){?>
                    <div id="hair_area_id" style="display: none;">
                        <select name="hair_area_id1" style="width: auto;" id="hair_area_id1"
                                data-action="{if isset($edit_goods_sign)}{:url('Sellergoodsonline/ajax_get_area_class')}{else/}{:url('Sellergoodsadd/ajax_get_area_class')}{/if}">
                            <option value="0">{$Think.lang.ds_please_choose}...</option>
                            {notempty name="top_area_class"}
                            {foreach name="top_area_class" item="v" key="k" }
                            <option value="{$v.area_id}">{$v.area_name}</option>
                            {/foreach}
                            {/notempty}
                        </select>

                        <select name="hair_area_id2" id="hair_area_id2" style="width: auto;">
                            <option value="">{$Think.lang.ds_please_choose}...</option>
                        </select><span></span>
                    </div>
                    <div id="edit_hair_area">{$goods_info['hair_address']}
                        <input type="button" value="编辑" style="font-size: 8px;width: 47px;!important;"
                               id="hair_edit_area_button">
                        <input type="hidden" name="hair_area_id1" value="{$goods_info.hair_area_id1}">
                        <input type="hidden" name="hair_area_id2" value="{$goods_info.hair_area_id2}"
                               id="edit_hair_area_id2">
                    </div>
                    <?php }else{ ?>
                    <select name="hair_area_id1" style="width: auto;" id="hair_area_id1"
                            data-action="{if isset($edit_goods_sign)}{:url('Sellergoodsonline/ajax_get_area_class')}{else/}{:url('Sellergoodsadd/ajax_get_area_class')}{/if}">
                        <option value="0">{$Think.lang.ds_please_choose}...</option>
                        {notempty name="top_area_class"}
                        {foreach name="top_area_class" item="v" key="k" }
                        <option value="{$v.area_id}">{$v.area_name}</option>
                        {/foreach}
                        {/notempty}
                    </select>
                    <select name="hair_area_id2" id="hair_area_id2" style="width: auto;">
                        <option value="">{$Think.lang.ds_please_choose}...</option>
                    </select><span></span>
                    <?php } ?>
                </td>
                <td class="vatop rowform onoff">
                    <span class="title">送货设置:</span>
                    <select name='waybill_type' style="width: auto;">
                        <option value="1"
                        <?php if(isset($goods_info['waybill_type'])&&$goods_info['waybill_type']== 1){?>
                        selected="selected"<?php }?> >自提+送货上门</option>
                        <option value="2"
                        <?php if(isset($goods_info['waybill_type'])&&$goods_info['waybill_type']== 2){?>
                        selected="selected"<?php }?> >自提</option>
                        <option value="3"
                        <?php if(isset($goods_info['waybill_type'])&&$goods_info['waybill_type']== 3){?>
                        selected="selected"<?php }?> >送货上门</option>
                    </select><span>1.自提：货物只配送到站点，需要客户自提；2.送货上门：货物默认配送到家，不收取费用；3.自提+送货上门：货物默认配送到站点，可支持配送到家，需要收取费用；</span>
                </td>

            </tr>

            <tr class="noborder">
                <td class="vatop rowform onoff">
                    <span class="title">商品重量:</span><input name="weight" value="{$goods_info.weight|default=''}"
                                                           type="text">kg<span></span>
                </td>
                <td class="vatop rowform onoff">
                    <span class="title">商品体积:</span><input name="volume" value="{$goods_info.volume|default=''}"
                                                           type="text">m³<span></span>
                </td>

            </tr>
            <tr class="noborder">
                <td class="vatop rowform onoff">
                    <span class="title">备货期:</span><input name="delivery_date"
                                                          value="{$goods_info.delivery_date|default=''}" type="text">
                    <p>几天后可以发货</p><span></span>
                </td>
                <td class="vatop rowform onoff">
                    <span class="title">商品包装:</span><input name="packing" value="{$goods_info.packing|default=''}"
                                                           type="text"><span></span>
                </td>
                <td class="vatop rowform onoff">
                </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform onoff">
                    <span class="title">包装尺寸-长:</span><input name="packing_long"
                                                             value="{$goods_info.packing_long|default=''}" type="text">m<span></span>
                </td>
                <td class="vatop rowform onoff">
                    <span class="title">包装尺寸-宽:</span><input name="packing_width"
                                                             value="{$goods_info.packing_width|default=''}" type="text">m<span></span>
                </td>

            </tr>
            <tr class="noborder">
                <td class="vatop rowform onoff">
                    <span class="title">包装尺寸-高:</span><input name="packing_high"
                                                             value="{$goods_info.packing_high|default=''}" type="text">m<span></span>
                </td>
                <td class="vatop rowform onoff">
                    <span class="title">质保期限:</span>
                    <select name='warranty_period' style="width: auto;">
                        <option value="">请选择</option>
                        <option value="1"
                        <?php if(isset($goods_info['warranty_period'])&&$goods_info['warranty_period']== 1){?>
                        selected="selected"<?php }?> >不包含</option>
                        <option value="2"
                        <?php if(isset($goods_info['warranty_period'])&&$goods_info['warranty_period']== 2){?>
                        selected="selected"<?php }?> >三个月</option>
                        <option value="3"
                        <?php if(isset($goods_info['warranty_period'])&&$goods_info['warranty_period']== 3){?>
                        selected="selected"<?php }?> >六个月</option>
                        <option value="4"
                        <?php if(isset($goods_info['warranty_period'])&&$goods_info['warranty_period']== 4){?>
                        selected="selected"<?php }?> >一年</option>
                        <option value="5"
                        <?php if(isset($goods_info['warranty_period'])&&$goods_info['warranty_period']== 5){?>
                        selected="selected"<?php }?> >两年</option>
                        <option value="6"
                        <?php if(isset($goods_info['warranty_period'])&&$goods_info['warranty_period']== 6){?>
                        selected="selected"<?php }?> >三年</option>
                    </select>
                </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform onoff"
                    style="flex-flow: column nowrap; align-items: start; flex: 0 0 100%; overflow: hidden;">
                    <span class="title">说明书上传:</span><input style="margin-top: -65px;" type="file" id="shuo_files"
                                                            name="files"
                                                            data-action="{:url('Sellergoodsadd/ajax_files')}">
                    <p class="hint">请上传后缀名为：.doc,.docx,.rtf,.xls,.xlsx,.pdf的文件</p>
                    <p>已上传文件：</p>
                    <span style="display: flex; flex-flow: column;" data_id='-1'>
                  <?php if(!empty($goods_info['files_info'])){
                                   foreach($goods_info['files_info']['old_file_name'] as $k=>$v){
                  ?>
                  <span data_id="{$k}"><input type='hidden' name="files[{$k}]"
                                              value="<?php echo $goods_info['files_info']['new_file_name'][$k]; ?>"/>
                      <input type='hidden' name="old_files[{$k}]" value="{$v}"/></br>
                      <input type='button' value='删除' class='del_file' style='font-size: 8px;width: 47px;'
                             data_id="{$k}" data_url="<?php echo $goods_info['files_info']['new_file_name'][$k]; ?>"/>&nbsp;&nbsp;&nbsp;&nbsp;{$v}</span>
                        <?php } }?>
                   </span></td>
            </tr>
            <tr>
                {if isset($goods_info.change_goods)}
                <td colspan="2" class="required top">
                    <label class="title">换货：</label>
                    <div class="onoff betton">
                        <label for="change_goods1"
                               class="cb-enable {if $goods_info.change_goods == 1}  selected  {/if}">支持</label>
                        <label for="change_goods0"
                               class="cb-disable {if $goods_info.change_goods == 0}  selected  {/if}">不支持</label>
                        <input id="change_goods1" name="change_goods" value="1" type="radio" {if
                               $goods_info.change_goods== 1} checked='checked' {/if}>
                        <input id="change_goods0" name="change_goods" value="0" type="radio" {if
                               $goods_info.change_goods== 0} checked='checked' {/if}>
                    </div>
                </td>
                {else/}
                <td colspan="2" class="required top">
                    <label class="title">换货：</label>
                    <div class="onoff betton">
                        <label for="change_goods1" class="cb-enable selected ">支持</label>
                        <label for="change_goods0" class="cb-disable ">不支持</label>
                        <input id="change_goods1" name="change_goods" value="1" type="radio" checked='checked'>
                        <input id="change_goods0" name="change_goods" value="0" type="radio">
                    </div>
                </td>
                {/if}


                {if isset($goods_info.return_goods)}
                <td colspan="2" class="required top">
                    <label class="title">退货：</label>
                    <div class="onoff betton">
                        <label for="return_goods1"
                               class="cb-enable {if $goods_info.return_goods == 1}  selected  {/if}">支持</label>
                        <label for="return_goods0"
                               class="cb-disable {if $goods_info.return_goods == 0}  selected  {/if}">不支持</label>
                        <input id="return_goods1" name="return_goods" value="1" type="radio" {if
                               $goods_info.return_goods== 1} checked='checked' {/if}>>
                        <input id="return_goods0" name="return_goods" value="0" type="radio" {if
                               $goods_info.return_goods== 0} checked='checked' {/if}>>
                    </div>
                </td>
                {else/}
                <td colspan="2" class="required top">
                    <label class="title">退货：</label>
                    <div class="onoff betton">
                        <label for="return_goods1" class="cb-enable selected">支持</label>
                        <label for="return_goods0" class="cb-disable ">不支持</label>
                        <input id="return_goods1" name="return_goods" value="1" type="radio" checked='checked'>
                        <input id="return_goods0" name="return_goods" value="0" type="radio">
                    </div>
                </td>

                {/if}
            </tr>
            <tr>
                {if isset($goods_info.goods_production)}
                <td colspan="2" class="required top">
                    <label class="title">生产/贴牌：</label>
                    <div class="onoff betton">
                        <label for="goods_production1"
                               class="cb-enable {if $goods_info.goods_production == 1}  selected {/if} ">生产</label>
                        <label for="goods_production2"
                               class="cb-disable {if $goods_info.goods_production == 2}  selected {/if}  ">贴牌</label>
                        <input id="goods_production1" name="goods_production" value="1" type="radio" {if
                               $goods_info.goods_production== 1} checked='checked' {/if}>
                        <input id="goods_production2" name="goods_production" value="2" type="radio" {if
                               $goods_info.goods_production== 2} checked='checked' {/if}>
                    </div>
                </td>
                {else/}
                <td colspan="2" class="required top">
                    <label class="title">生产/贴牌：</label>
                    <div class="onoff betton">
                        <label for="goods_production1" class="cb-enable selected">生产</label>
                        <label for="goods_production2" class="cb-disable ">贴牌</label>
                        <input id="goods_production1" name="goods_production" value="1" type="radio" checked='checked'>
                        <input id="goods_production2" name="goods_production" value="2" type="radio">
                    </div>
                </td>

                {/if}

                {if isset($goods_info.is_w_v)}
                <td colspan="2" class="required top">
                    <label class="title">抛货/重货：</label>
                    <div class="onoff betton">

                        <label for="is_w_v1"
                               class="cb-enable {if $goods_info.is_w_v == 1}  selected {/if} "><span>抛货</span></label>
                        <label for="is_w_v0"
                               class="cb-disable {if $goods_info.is_w_v == 2}  selected {/if} "><span>重货</span></label>
                        <input id="is_w_v1" name="is_w_v" value="1" type="radio" {if $goods_info.is_w_v== 1}
                               checked='checked' {/if} >
                        <input id="is_w_v0" name="is_w_v" value="2" type="radio" {if $goods_info.is_w_v== 2}
                               checked='checked' {/if}>
                    </div>
                </td>

                {else /}
                <td colspan="2" class="required top">
                    <label class="title">抛货/重货：</label>
                    <div class="onoff betton">

                        <label for="is_w_v1"
                               class="cb-enable selected"><span>抛货</span></label>
                        <label for="is_w_v0"
                               class="cb-disable"><span>重货</span></label>
                        <input id="is_w_v1" name="is_w_v" value="1" checked="checked" type="radio">
                        <input id="is_w_v0" name="is_w_v" value="2" type="radio">
                    </div>
                </td>

                {/if}

</tr>
<tr>
    {if isset($goods_info.is_to_pay)}
    <td colspan="2" class="required top" id="is_to_pay">
        <label class="title">到付：</label>
        <div class="onoff betton">
            <label for="is_to_pay1" class="cb-enable  {if $goods_info.is_to_pay == 1} selected {/if} ">支持</label>
            <label for="is_to_pay0" class="cb-disable {if $goods_info.is_to_pay == 0} selected {/if}">不支持</label>
            <input id="is_to_pay1" name="is_to_pay" value="1" type="radio" {if $goods_info.is_to_pay== 1}
                   checked='checked' {/if}>

            <input id="is_to_pay0" name="is_to_pay" value="0" type="radio" {if $goods_info.is_to_pay== 0}
                   checked='checked' {/if}>
        </div>
    </td>
    {else /}
    <td colspan="2" class="required top" id="is_to_pay">
        <label class="title">到付：</label>
        <div class="onoff betton">
            <label for="is_to_pay1" class="cb-enable selected">支持</label>
            <label for="is_to_pay0" class="cb-disable ">不支持</label>
            <input id="is_to_pay1" name="is_to_pay" value="1" type="radio" checked='checked'>
            <input id="is_to_pay0" name="is_to_pay" value="0" type="radio">
        </div>
    </td>

    {/if}
</tr>
<tr>


</tr>


</tbody>
<tfoot>
<tr class="tfoot">
    <td colspan="2">
        <input type='submit' class="btn" value="{$Think.lang.ds_submit}"/>
    </td>

</tr>
</tfoot>
</table>
</form></div>
<script>
    $(function () {

        //编辑商品产地地址
        $(document).on('click', '#edit_area_button', function () {
            $('#edit_area').remove();
            $('#save_area').show();
        });

        //编辑商品发货地
        $(document).on('click', '#hair_edit_area_button', function () {
            $('#edit_hair_area').remove();
            $('#hair_area_id').show();
        });


        jQuery.validator.addMethod("checkFCodePrefix", function (value, element) {
            return this.optional(element) || /^[a-zA-Z]+$/.test(value);
        }, '{$Think.lang.prompt_information1}');


        $('#remark_form').validate({
            errorPlacement: function (error, element) {
                $(element).nextAll('span').append(error);
            },
            rules: {
                b_name: {
                    required: true,
                },
                waybill_id: {
                    required: true,
                },
                packing: {
                    required: true,
                },
                packing_long: {
                    required: true,
                    number: true,
                    min: 0.01,
                },
                packing_width: {
                    required: true,
                    number: true,
                    min: 0.01,
                },
                packing_high: {
                    required: true,
                    number: true,
                    min: 0.01,
                },
                weight: {
                    required: true,
                    number: true,
                    min: 0.01,
                },
                volume: {
                    required: true,
                    number: true,
                    min: 0.01,
                },
                goods_code: {
                    required: true,
                },
                goods_production: {
                    required: true,
                },

                goods_factory: {
                    required: true,
                },
                delivery_date: {
                    required: true,
                    digits: true,
                    min: 0,
                },
                g_vindate: {
                    required: function () {
                        if ($("#is_gv_1").prop("checked")) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                },
            },
            messages: {
                goods_code: {
                    required: '{$Think.lang.store_goods_index_goods_code_null}'
                },
                waybill_id: {
                    required: '不能为空'
                },
                weight: {
                    required: '不能为空',
                    number: '请设置正确的数值',
                    min: '请设置正确的数值',
                },
                volume: {
                    required: '不能为空',
                    number: '请设置正确的数值',
                    min: '请设置正确的数值',
                },
                packing: {
                    required: '不能为空'
                },
                goods_body: {
                    required: '不能为空'
                },
                delivery_date: {
                    required: '不能为空',
                    digits: '此数值需要是正整数',
                    required: '设置的数值需要大于零',
                },
                packing_long: {
                    required: '不能为空',
                    number: '请设置正确的数值',
                    min: '请设置正确的数值',
                },
                packing_width: {
                    required: '不能为空',
                    number: '请设置正确的数值',
                    min: '请设置正确的数值',
                },
                packing_high: {
                    required: '不能为空',
                    number: '请设置正确的数值',
                    min: '请设置正确的数值',
                },

                goods_production: {
                    required: '不能为空'
                },

                goods_band_name: {
                    required: '{$Think.lang.store_goods_index_goods_band_name_null}'
                },

                goods_factory: {
                    required: '{$Think.lang.store_goods_index_goods_factory_null}'

                },
                b_name: {
                    required: '不能为空'
                },
            }
        });

        //商品产地
        $('#area_id1').change(function () {
            var htmls = '<option value="">请选择...</option>';
            $('#area_id2').html(htmls);
            var area_id = $(this).val();
            var url = $(this).attr('data-action');
            if (area_id == '0') {
                var htmls = '<option value="">请选择...</option>';
                $('#area_id2').html(htmls);
            } else {
                // alert(area_id);return false;
                $.ajax({
                    //请求方式
                    type: "POST",
                    //请求地址
                    url: url,
                    //数据，json字符串
                    data: {'area_id': area_id},
                    //请求成功
                    success: function (result) {

                        var htmls = '<option value="">请选择...</option>';
                        $.each(result, function (item, v) {
                            htmls += "<option value='" + v.area_id + "'>" + v.area_name + "</option>";
                        });

                        $('#area_id2').html(htmls);
                    },
                    //请求失败，包含具体的错误信息
                    error: function (e) {
                        console.log(e.status);
                        console.log(e.responseText);
                    }
                });
            }
        });

        //商品发货地
        $('#hair_area_id1').change(function () {
            var htmls = '<option value="">请选择...</option>';
            $('#hair_area_id2').html(htmls);
            var area_id = $(this).val();
            var url = $(this).attr('data-action');
            if (area_id == '0') {
                var htmls = '<option value="">请选择...</option>';
                $('#hair_area_id2').html(htmls);
            } else {
                $.ajax({
                    //请求方式
                    type: "POST",
                    //请求地址
                    url: url,
                    //数据，json字符串
                    data: {'area_id': area_id},
                    //请求成功
                    success: function (result) {

                        var htmls = '<option value="">请选择...</option>';
                        $.each(result, function (item, v) {
                            htmls += "<option value='" + v.area_id + "'>" + v.area_name + "</option>";
                        });

                        $('#hair_area_id2').html(htmls);
                    },
                    //请求失败，包含具体的错误信息
                    error: function (e) {
                        console.log(e.status);
                        console.log(e.responseText);
                    }
                });
            }
        });


        //说明书删除
        $(document).on('click', '.del_file', function () {
            var data_id = $(this).attr('data_id');
            var data_url = $(this).attr('data_url');
            var html = "<input type='hidden' name='del_file[" + data_id + "]' value='" + data_url + "' />";
            $(this).parent().html(html);
            layer.msg('删除成功');
        });

        //说明书上传并展示
        $(document).on('change', '#shuo_files', function () {
            $('#dataLoading').show();
            var files = document.getElementById('shuo_files').files[0];
            var lastId = $(this).parent().find('span').last().attr('data_id');
            var lastid = parseInt(lastId) + 1;
            var obj = $(this).next().next().next();
            var formData = new FormData();
            var objs = $(this);
            formData.append('file', files);
            var url = $(this).attr('data-action');
            layer.msg('正在上传');
            $.ajax({
                //请求方式
                type: "POST",
                //请求地址
                url: url,
                data: formData,
                cache: false,  //默认是true，但是一般不做缓存
                processData: false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
                contentType: false,  //一些文件上传http协议的关系，自行百度，如果上传的有文件，那么只能设置为false
                //请求成功
                success: function (result) {
                    if (result.msg == 1) {
                        objs.val('');
                        layer.msg('上传成功');
                        var html = "<span data_id='" + lastid + "' ><input type='hidden' name='files[" + lastid + "]'  value='" + result.files_name + "'  /><input type='hidden' name='old_files[" + lastid + "]'  value='" + result.old_name + "'  /></br><input type='button' value='删除' class='del_file' style='font-size: 8px;width: 47px;' data_id='" + lastid + "' data_url='" + result.files_name + "'/>&nbsp;&nbsp;&nbsp;&nbsp;" + result.old_name + "</span>";
                        obj.append(html);
                    } else {
                        objs.val('');
                        layer.msg('文件信息错误,请重新上传');
                        return false;
                    }

                },
                //请求失败，包含具体的错误信息
                error: function (e) {
                    console.log(e.status);
                    console.log(e.responseText);
                }
            });

        });

        $("form").submit(function (e) {
            var res = $("#remark_form").valid();
            var save_area_id2 = $('#save_area_id2').val();
            var area_id2 = $('#area_id2').val();
            if (typeof save_area_id2 == 'undefined' || save_area_id2 == '' || save_area_id2 == null) {
                if (typeof area_id2 == 'undefined' || area_id2 == '' || area_id2 == null) {
                    layer.msg('请选择商品产地');
                    return false;
                }
            }
            var hair_area_id2 = $('#hair_area_id2').val();
            var edit_hair_area_id2 = $('#edit_hair_area_id2').val();

            if (typeof edit_hair_area_id2 == 'undefined' || edit_hair_area_id2 == '' || edit_hair_area_id2 == null) {
                if (typeof hair_area_id2 == 'undefined' || hair_area_id2 == '' || hair_area_id2 == null) {
                    layer.msg('请选择商品发货地');
                    return false;
                }
            }

            if (res) {
                var url = $('form').attr('action');
                $.ajax({
                    type: "POST",
                    url: url,
                    data: $('#remark_form').serialize(),// 你的formid
                    error: function (request) {
                        alert("Connection error");
                    },
                    success: function (result) {


                        //  alert(result);return false;
                        if (result.code == 0) {
                            layer.closeAll();
                            layer.msg('完善成功');
                            parent.location.reload();
                            return false;
                        } else {
                            layer.closeAll();
                            layer.msg('完善失败');
                            parent.location.reload();
                            return false;
                        }
                    }
                });
                return false;


            }

        });

    });

</script>